const { defineConfig } = require('@vue/cli-service')
const Mock = require('mockjs')

const data = Mock.mock({
  "list|10": [{
    "id": "@id",
    "title": "@ctitle",
    "sell|10-100000": 1,
    "transportationPrice|0-10": 1,
    "image": "@image(100x100, @color)",
    "items|3": [{
      "id": "@id",
      "image": "@image(100x100, @color)",
      "title": "@ctitle",
      "price|1-200.1-2": 1
    }]
  }]
})

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    setupMiddlewares(middlewares, devServer) {
      devServer.app.get('/list', (req, res) => {
        res.send(data.list)
      })
      return middlewares
    }
  }
})
